package com.jctrip.hotel.source.util;


import org.springframework.util.DigestUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * @Author: zxy
 * @CreateTime: 2023-08-21 15:53
 * @Description:
 */
public class ElongUtil {
    /**
     * 生成艺龙接口签名
     */
    public static String getSign(String appKey, String secretKey, String timestamp, String request) {
        return DigestUtils.md5DigestAsHex((timestamp + DigestUtils.md5DigestAsHex((request + appKey).getBytes()) + secretKey).getBytes());
    }

    /**
     * 艺龙data封装
     * @param data
     * @return
     */
    public static String getUrlEncoder(String data){
        try{
            return URLEncoder.encode(data, "UTF-8");
        } catch (UnsupportedEncodingException e){
            throw new RuntimeException(e.getMessage());
        }
    }
}
